
import store from "@/index/store";

import { createRouter,createWebHistory } from "vue-router";

import routes from "./routes.js";
import axiosRoutes from "./routes/axiosRoutes.js";
import compositionRoutes from "./routes/compositionRoutes.js";
import errorRoute from "./routes/errorRoute";
import routerRoutes from "./routes/routerRoutes";
import singleRoutes from "./routes/singleRoutes";
import styleRoutes from "./routes/styleRoutes";
import vuexRoutes from "./routes/vuexRoutes";

const router =  createRouter({
    history:createWebHistory(process.env.BASE_URL),
    linkActiveClass:"active",
    linkExactActiveClass:"exact-active",
    // routes:routes
    routes:[
        ...routes,
        ...axiosRoutes,
        ...compositionRoutes,
        ...errorRoute,
        ...routerRoutes,
        ...singleRoutes,
        ...styleRoutes,
        ...vuexRoutes
    ]
})

router.beforeEach( function(){
    console.log("全局进入守卫",store.state.msg)

    // let num = Math.random();
    // // let num = 0.6;
    // console.log(num);

    // if(num<=0.8){
    //     return {
    //         path:"/axios"
    //     }
    // }else{
    //     return true
    // }
} )

export default router;